<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!--0:引入 vue.js-->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        div{
            width: 300px;
            height: 100px;
            margin: 20px;
        }
        #id1{
            background-color: cyan;
        }

        #id2{
            background-color: darkgoldenrod;
        }
    </style>
</head>
<body>
    <div id="app8">
        <div id = "id1" @click = "doit">

        </div>

        <div id ="id2">

        </div>
    </div>


    <script>
        let vm = new Vue({
            el:"#app8",
            data:{},
            methods:{
                doit(e){
                    console.log(`点击位置在id1上:x:${e.offsetX},y:${e.offsetY}`);
                }
            }
        })
    </script>
    
</body>
</html>